package com.xsz.order.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.xsz.order.enums.OrderStatus;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 查询order form
 * @author zhusijie
 * @date 2020/6/4
 */
@Data
public class QueryOrderForm implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 订单ID
     */
    private String orderId;

    /**
     * 用户编号
     */
    private long userId;

    /**
     * 订单状态
     */
    private List<OrderStatus> statuses;

    /**
     * 收货人姓名
     */
    private String orderUserName;
    public String getOrderUserName(){
        return StringUtils.hasText(orderUserName) ? String.format("%%%s%%", orderUserName) : orderUserName;
    }

    /**
     * 取餐时间下限
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime takeMealTimeLower;

    /**
     * 取餐时间上限
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime takeMealTimeUpper;
}
